from django.contrib.auth.models import AbstractUser
from django.db import models
from plc_ai_backend.utils.base_modle import BaseModel


# Create your models here.

class MenuModel(BaseModel):
    number = models.IntegerField("排序数字", blank=True, null=True)
    url = models.CharField("排序数字", max_length=256, blank=True, null=True)
    name = models.CharField("菜单名字", max_length=256, blank=True, null=True)
    delete_flag = models.CharField("删除标记", max_length=1, default="0")
    parent = models.ForeignKey("self", max_length=1, default="0", related_name="children", blank=True, null=True,
                               on_delete=models.CASCADE)

    class Meta:
        db_table = "t_menu"
        verbose_name = "功能菜单表"
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name


class UserModel(BaseModel, AbstractUser):
    phone = models.CharField("排序数字", max_length=11, blank=True, null=True)
    real_name = models.CharField("菜单名字", max_length=24, blank=True, null=True)

    class Meta:
        db_table = "t_user"
        verbose_name = "用户表"
        verbose_name_plural = verbose_name
